<template>
	<div>
		<div class="tabNav">
			<router-link to="/index">
                <img src="../assets/img/sidebar1.png" />首页
            </router-link>
			<b>/<img src="../assets/img/lhyg.png" />服务者协议</b>
		</div>
		<el-row :gutter="24">
			<el-col :span="24">
				<el-card class="cardTits cardTitss cardTitdd invoiceManage table-drop" shadow="hover">
					<div class="search">
					<el-input
						placeholder="服务者名称"
						v-model="searchVal1"
					></el-input>
                    <el-input
						placeholder="企业名称"
						v-model="searchVal2"
					></el-input>
                    <el-input
						placeholder="税源地名称"
						v-model="searchVal3"
					></el-input>
					<el-button type="primary" @click="search()">查询</el-button>
					</div>
					<el-table :data="tableData" stripe style="width: 100%" @sort-change="sortChange">
						<el-table-column width="30">
						</el-table-column>
						<el-table-column prop="id" sortable="custom" width="100" label="ID">
						</el-table-column>
						<el-table-column prop="personName" sortable="custom" label="服务者名称">
						</el-table-column>
                        <el-table-column prop="idCard" sortable="custom" label="身份证号">
						</el-table-column>
                        <el-table-column prop="businessNo" sortable="custom" label="企业编号">
						</el-table-column>
                        <el-table-column prop="businessName" sortable="custom" label="企业名称">
						</el-table-column>
                        <el-table-column prop="authBusinessName" sortable="custom" label="税源地名称">
						</el-table-column>
                        <el-table-column
                            prop="caozuo"
                            label="操作"
                            width="140"
                            class-name="editor"
                            >
                            <template #default="item">
                            <el-button type="text" @click="openUrl(item.row.agreementUrl)">下载协议</el-button>
                        </template>
                        </el-table-column>
					</el-table>
					<el-pagination v-if="tableData.length > 0" @size-change="handleSizeChange" @current-change="handleCurrentChange"
						:current-page="currentPage" :page-sizes="arrPage" :page-size="selectPage"
						layout="total, sizes, prev, pager, next, jumper" :total="renwuTotals">
					</el-pagination>
				</el-card>
			</el-col>
		</el-row>
	</div>
</template>

<script>
	export default {
		name: "dashboard",
		data() {
			return {
				settlementStatus: {
					// 结算状态
					1: "未打款",
					2: "已打款",
					3: "已作废",
				},
				// {
				// value: '',
				// label: '全部'
				// },
				options: [{
				value: '1',
				label: '充值'
				},{
				value: '2',
				label: '退款'
				},],
				options1: {
					1: "充值",
					2: "退款",
				},
				excelDownloadShow: false,
				SelectPlatformData: {}, // 灵活用功平台信息
				orderByZH: false,
				orderByAsc: false,
				orderByColume: 'createTime',
				currentPage: 1,
				renwuTotals: 0, // 结算任务明细总条数
				total: 0, // 总条数
				arrPage: [10, 20], // 每页条数
				selectPage: 10, // 每页选中条数
				tableData: [],
				tableData1: [],
				value: '',
				value1: '',
				searchVal1: '',
                searchVal2: '',
                searchVal3: '',
				rechargeType: '',
				startTime: '',
				endTime: '',
				serveTime: '',
				auditStatus: {
					0: '待审核'
				},
				id: '',
				busid: ''
			};
		},
		components: {},
		mounted() {
			// this.getTableData();
			this.getSelectPlatform()
		},
		computed: {
			role() {
				return this.name === "admin" ? "超级管理员" : "普通用户";
			}
		},

		methods: {
            openUrl(url) {
				// window.open('/pdfjs/web/viewer.html?file=' + encodeURIComponent(url))
                window.open(url)
            },
			search(){
				this.getSelectPlatform();
			},
			handleSizeChange(val) {
				this.selectPage = val
				this.getSelectPlatform()
			},
			handleCurrentChange(val) {
				// 切换当前页
				this.currentPage = val
				this.getSelectPlatform()
			},
			getSelectPlatform() {
				if(this.value1){
					this.endTime = this.value1[1]
					this.startTime = this.value1[0]
				}else {
					this.endTime = ''
					this.startTime = ''
				}
				// 平台端查询企业充值记录
				this.$http({
					url: '/api/quick/agreement/getPersonAgreementPage',
					method: 'post',
					headers: {
						'Content-Type': 'application/json'
					},
					data: {
						personName: this.searchVal1,
                        businessName: this.searchVal2,
                        authBusinessName: this.searchVal3,
						"pageNum": this.currentPage,
						"pageSize": this.selectPage,
						orderByAsc: this.orderByAsc, // 是否正序
						orderByColume: this.orderByColume, // 排序字段
						orderByZH: this.orderByZH, // 是否汉字
					}
				}).then(data => {
					if(data.code === 0) {
						this.tableData = data.result.list
						this.renwuTotals = data.result.total
					}
				})
			},
			settlementDetails(id, busid) {
				// 结算任务明细
				this.id = id
				this.busid = busid
				this.settlementDetailShow = true
				this.getRenwuTableData(1, 10)
			},
			renwuCurrentChange(val) {
				// 结算任务明细切换分页
				this.renwuCurrentPage = val
				this.getRenwuTableData(this.renwuCurrentPage, 10)
			},
			renwuPageChange(val) {
				// 结算任务明细切换当前页显示条数
				this.renwuSelectPage = val
				this.renwuCurrentPage = 1
				this.getRenwuTableData(1, this.renwuSelectPage)
			},
			sortChange(d) {
				// 监听排序
				if(d.prop == null) {
					// 默认排序方式
					this.orderByZH = false
					this.orderByAsc = false
					this.orderByColume = 'createTime'
				}else {
					let orderByZH = false
					if(d.id == "legalName"|| d.id == "receiveBank") {
						orderByZH = true
					}
					this.currentPage = 1
					this.selectPage = 10
					let orderByAsc = d.order == "descending" ? false : true
					this.orderByZH = orderByZH
					this.orderByAsc = orderByAsc
					this.orderByColume = d.id
				}
				this.getTableData();
			},
			sortChange1(d) {
				// 监听排序
				if(d.prop == null) {
					// 默认排序方式
					this.orderByZH = false
					this.orderByAsc = false
					this.orderByColume = 'createTime'
				}else {
					let orderByZH = false
					if(d.id == "taskName"|| d.id == "legalName") {
						orderByZH = true
					}
					this.currentPage = 1
					this.selectPage = 10
					let orderByAsc = d.order == "descending" ? false : true
					this.orderByZH = orderByZH
					this.orderByAsc = orderByAsc
					this.orderByColume = d.id
				}
				this.getRenwuTableData(1, this.renwuSelectPage)
			},
		}
	};
</script>
<style scoped>
.tabNav strike {
	color: #dd0b01;
    font-weight: bold;
    text-decoration: none;
}
.cardTit {
    color: rgba(10, 46, 106, 1);
    line-height: 50px;
    padding-left: 20px;
    font-size: 14px;
    font-weight: normal;
}
.excelDownload {
    position: absolute;
    right: 30px;
    top: 10px;
    cursor: pointer;
    z-index: 111;
}
.serveTime {
	float: left;
    margin-left: 50px;
    position: relative;
    top: 10px;
}
.showCloro {
	cursor: pointer;
	color: #326CF0;
    text-align: left;
}
</style>